﻿using System;
using System.Xml;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Genko.Model;
using Genko.Model.Integration;

namespace Genko.TestApp
{
	public partial class ModelForm : Form
	{
		public ModelForm()
		{
			InitializeComponent();
		}

		private void LoadButton_Click(object sender, EventArgs e)
		{
			LoadModel(ModelTextBox.Text);
		}

		private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
		{
			Application.Exit();
		}
		
		protected void LoadModel(string xmlModel)
		{
			try {
				Scheme scheme = new Scheme();
				IMemberAdapter adapter = XmlAdapterFactory.CreateAdapter(xmlModel);
				adapter.FillException += new FillExceptionEventHandler(adapter_FillException);
				adapter.Fill(scheme.Schemas);
				scheme.Validation += new ValidationEventHandler(scheme_Validation);
				scheme.Validate();
			} catch (Exception e) {
				MessageBox.Show(e.Message);
			}
		}

		private void scheme_Validation(object sender, ValidationEventArgs args)
		{
			
		}

		private void adapter_FillException(object sender, FillExceptionEventArgs e)
		{
			
		}
	}
}
